<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Converts keys specifying an index to its identifying string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.setslaveokay.html">MongoCollection::setSlaveOkay</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocollection.--tostring.html">MongoCollection::__toString</a></div>
 <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongocollection.toindexstring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::toIndexString</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::toIndexString</span> &mdash; <span class="dc-title">Converts keys specifying an index to its identifying string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocollection.toindexstring-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">static protected</span> <span class="type">string</span> <span class="methodname"><strong>MongoCollection::toIndexString</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$keys</code></span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongocollection.toindexstring-parameters">
  <h3 class="title">参数</h3>  
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">keys</code></em>
     </dt>

     <dd>

      <p class="para">
       Field or fields to convert to the identifying string
      </p>
     </dd>

       
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocollection.toindexstring-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a string that describes the index.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocollection.toindexstring-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1437">
   <p><strong>Example #1 <span class="function"><strong>MongoCollection::toIndexString()</strong></span> example</strong></p>
   <div class="example-contents"><p>This example shows how you can create an index name out of of keys.
   Because this is a protected (static) method, you need to overload it in a
   child class first.</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;inherited&nbsp;class&nbsp;to&nbsp;make&nbsp;the&nbsp;method&nbsp;"public".<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">MyCollection&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">MongoCollection<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />echo&nbsp;</span><span style="color: #0000BB">MyCollection</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;Outputs:&nbsp;foo_1<br /><br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">MyCollection</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'age'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">)),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;Outputs:&nbsp;name_1_age_-1<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocollection.toindexstring-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   MongoDB core docs on <a href="http://docs.mongodb.org/manual/indexes/" class="link external">&raquo;&nbsp;indexes</a>.
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.setslaveokay.html">MongoCollection::setSlaveOkay</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocollection.--tostring.html">MongoCollection::__toString</a></div>
 <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
